package com.google.screen;

import com.google.zxing.client.android.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

public class MyExLstView extends BaseExpandableListAdapter {

	private Context mCtx;
	private String[] mStrQuestions = { "Who are you?", "Where are you from?",
			"How do you do?", "What do you want?", "Can you help me?" };
	private String[][] mStrAnswers = { { "My name Rafael." },
			{ "I am from Viet Nam." }, { "I am fine." },
			{ "I want to become programmer." }, { "I am ready." } };

	public MyExLstView(Context ctx) {
		mCtx = ctx;
	}

	@Override
	public Object getChild(int arg0, int arg1) {
		return null;
	}

	@Override
	public long getChildId(int arg0, int arg1) {
		return 0;
	}

	@Override
	public View getChildView(int arg0, int arg1, boolean arg2, View arg3,
			ViewGroup arg4) {
		if (arg3 == null) {
			LayoutInflater inf = (LayoutInflater) mCtx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			arg3 = inf.inflate(R.layout.answers, null);
		}
		TextView tv = (TextView) arg3.findViewById(R.id.exlstAnswers); 
		tv.setText(mStrAnswers[arg0][arg1]);
		return arg3;
	}

	@Override
	public int getChildrenCount(int arg0) {
		return mStrAnswers[arg0].length;
	}

	@Override
	public Object getGroup(int arg0) {
		return arg0;
	}

	@Override
	public int getGroupCount() {
		return mStrQuestions.length;
	}

	@Override
	public long getGroupId(int arg0) {
		return arg0;
	}

	@Override
	public View getGroupView(int arg0, boolean arg1, View arg2, ViewGroup arg3) {
		if (arg2 == null) {
			LayoutInflater inf = (LayoutInflater) mCtx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			arg2 = inf.inflate(R.layout.questions, null);
		}
		TextView tv = (TextView) arg2.findViewById(R.id.exlstQuestions); 
		tv.setText(mStrQuestions[arg0]);
		return arg2;
	}

	@Override
	public boolean hasStableIds() {
		return false;
	}

	@Override
	public boolean isChildSelectable(int arg0, int arg1) {
		return true;
	}

}
